1 00:00:00,450 --> 00:00:02,930 Hello and welcome to this lecture. 2 00:00:03,090 --> 00:00:11,820 In this lecture we will be creating a function that we will use to draw the paddle. 3 00:00:12,820 --> 00:00:21,030 I am going to create a function now called draw paddle wing creative functions is geared to name your 4 00:00:21,030 --> 00:00:23,710 functions appropriately. 5 00:00:24,060 --> 00:00:28,320 So the closer the name is to what you're trying to do that better. 6 00:00:28,350 --> 00:00:31,090 For example here we've got a function called drop ball. 7 00:00:31,140 --> 00:00:35,440 So is self-explanatory we know what that function scanner too. 8 00:00:35,520 --> 00:00:42,750 So what I'm going to do to create the drop pad of function I'm just going to copy this entire function 9 00:00:42,780 --> 00:00:47,130 here and just change some of the values just to save some time here. 10 00:00:47,130 --> 00:00:52,160 So I just go paste I'm going to change is to drop pando. 11 00:00:59,000 --> 00:01:05,740 All right so I've changed the name to draw a paddle an hour leave a lot of the most fun challenge you 12 00:01:05,740 --> 00:01:14,540 can have a big in parts of this is a contents contexts don't begin part and then where we go. 13 00:01:14,560 --> 00:01:16,060 We're not going to do an arc. 14 00:01:16,060 --> 00:01:18,280 This was what we used to quit the ball. 15 00:01:18,550 --> 00:01:27,690 What we're trying to do is create a paddle so gonna use the wreck to see context or rest for rectangle. 16 00:01:27,700 --> 00:01:36,530 And then in between the parentheses we are going to create the valleys are the parameters that will 17 00:01:36,530 --> 00:01:40,710 be used to create the paddle. 18 00:01:40,780 --> 00:01:52,300 All right the first time if I'm gonna pass into this context are wrecked is the paddle x variable type 19 00:01:52,320 --> 00:02:06,970 in paddle and is upper case X. The next time if I'm going to include is the height of the canvas minus 20 00:02:07,090 --> 00:02:08,600 the paddle height. 21 00:02:08,620 --> 00:02:10,390 When will the time being come that's 22 00:02:13,230 --> 00:02:25,170 come as dropped Heights which means the height of the canvas minus paddle height. 23 00:02:25,180 --> 00:02:31,840 But we've got a variable here core puddle height so angle of mine was the height of the -- bus from 24 00:02:31,990 --> 00:02:42,450 the paddle height comma the next week go into parsee is the width of the paddle we go. 25 00:02:42,490 --> 00:02:47,610 PAOLO We have already got a variable called paddle. 26 00:02:47,610 --> 00:02:53,640 We've defined their necks. 27 00:02:53,750 --> 00:03:00,670 We're going to apply the puddle height variable power do. 28 00:03:03,880 --> 00:03:04,920 Right. 29 00:03:05,790 --> 00:03:11,890 All right so file in these creation of the paddle in the contents are wrecked. 30 00:03:11,900 --> 00:03:13,640 We have got several perimeters. 31 00:03:13,640 --> 00:03:15,250 We've caught the paddle. 32 00:03:15,320 --> 00:03:21,050 EX What time is the starting point for the x axis. 33 00:03:21,240 --> 00:03:29,010 And then we've got the cumbersome height which is the height of the Cambers minus the paddle height 34 00:03:29,800 --> 00:03:36,960 command and then we have also passed in another on apparently which is a paddle with and then pass then 35 00:03:36,990 --> 00:03:39,870 the paddle height as well. 36 00:03:39,870 --> 00:03:48,770 Next we want to apply a context feel the colour will use to collar the iPad. 37 00:03:49,080 --> 00:03:52,070 I will make it blue. 38 00:03:52,190 --> 00:03:54,200 You can make yours whatever you like. 39 00:03:54,210 --> 00:03:56,610 I just make my blue. 40 00:03:56,700 --> 00:04:00,450 And then this is what will actually do the fill in this method here. 41 00:04:00,450 --> 00:04:03,750 Context Dr. Phil hand there. 42 00:04:03,780 --> 00:04:04,640 We've got that. 43 00:04:04,680 --> 00:04:06,530 That will close. 44 00:04:06,580 --> 00:04:08,700 We've got begin and then go closer. 45 00:04:08,700 --> 00:04:17,590 This closes the function so you can see how much pull a semicolon at the end of each line. 46 00:04:17,600 --> 00:04:25,050 It's very important that the cause would just grip and most programming language they work with instructions 47 00:04:25,200 --> 00:04:30,230 line by line so that indicates that these instructions on this line is finished. 48 00:04:30,330 --> 00:04:32,300 And then he jumps on to the next line. 49 00:04:32,340 --> 00:04:39,140 So we have now drawn created a function to draw the panel. 50 00:04:39,330 --> 00:04:47,120 OK so this is a function to create the sort of click on save to save your work so far. 51 00:04:48,140 --> 00:04:52,460 I've saved my work if I refresh you. 52 00:04:52,470 --> 00:04:56,710 You should not see the iPad or yet. 53 00:04:57,320 --> 00:04:57,840 OK. 54 00:04:57,910 --> 00:05:04,520 We have defined the function we have created a function that would draw the paddle. 55 00:05:04,540 --> 00:05:14,670 The paddle is not visible on the canvas yet that is because we have not called it a dot We've created 56 00:05:14,670 --> 00:05:14,850 it. 57 00:05:14,850 --> 00:05:17,730 We need to call it into action. 58 00:05:17,850 --> 00:05:23,030 So to do that we are going to insert it. 59 00:05:23,250 --> 00:05:31,510 We need we need to insert a line that will core this function to draw the podium so let's do that. 60 00:05:31,920 --> 00:05:40,470 All right to call the function we've just created the drop pad of function we need to call it from the 61 00:05:40,470 --> 00:05:47,520 draw function we've got a function here called draw where we've got a draw ball here defined this is 62 00:05:47,520 --> 00:05:51,450 where we call all called the draw ball function. 63 00:05:51,450 --> 00:05:58,810 So to call the draw paddle functioning to action we need to call it from here. 64 00:05:58,830 --> 00:06:00,710 So I just type in draw 65 00:06:04,200 --> 00:06:18,840 grew up had a very good list and then just grab a pad and then kind of semigroups k if i say that the 66 00:06:18,990 --> 00:06:22,460 fact that means I've saved that and refresh my browser. 67 00:06:22,470 --> 00:06:30,240 You should call this function here and he will draw it paddles so this function drop calls to function 68 00:06:30,630 --> 00:06:34,000 causing trouble to drop the ball and it was all core. 69 00:06:34,020 --> 00:06:37,070 The drop paddle to draw the paddle. 70 00:06:37,170 --> 00:06:41,170 So lets me refresh and you can see. 71 00:06:41,580 --> 00:06:46,410 You can see that that's the shadow they are do a paddle has got no action. 72 00:06:46,410 --> 00:06:48,720 It does move at the moment by Lyss. 73 00:06:48,720 --> 00:06:55,180 We've drawn the paddle thank you so much for your time in this lecture. 74 00:06:55,290 --> 00:06:59,820 Please let me know if you've got any questions whatsoever. 75 00:07:00,270 --> 00:07:09,430 In the next lecture we are going to be creating some control that will use to control the puddle.